package com.ibl.rover.lite.common.bean;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

public class AppSetupBean extends BaseBean {

	@ColumnOrder(Order = 1)
	private String code;
	@ColumnOrder(Order = 2)
	private String lastOrder;
	@ColumnOrder(Order = 3)
	private String name;

	private static AutomatedQueryStatement AUTO_GEN_QUERY;

	public static final String COL_CODE = "CODE";
	public static final String COL_LAST_ORDER = "LAST_ORDER";
	public static final String COL_NAME = "NAME";

	public static final int IDX_COL_CODE = 1;
	public static final int IDX_COL_LAST_ORDER = 2;
	public static final int IDX_COL_NAME = 3;

	static {
		AUTO_GEN_QUERY = SQLiteDatabaseHelper
				.getAutoGeneratedStmts(AppSetupBean.class);
	}

	public AppSetupBean() {

	}

	@Override
	public void bind(SQLiteStatement sqlLiteStatement) {
		sqlLiteStatement.bindString(IDX_COL_CODE, code);
		sqlLiteStatement.bindString(IDX_COL_LAST_ORDER, lastOrder);
		sqlLiteStatement.bindString(IDX_COL_NAME, name);

	}

	@Override
	public <T extends BaseBean> T cursorBind(Cursor cursor) {
		AppSetupBean appSetupBean = new AppSetupBean();
		appSetupBean.set_id(cursor.getInt(IDX_COL_ID));
		appSetupBean.setLastOrder(cursor.getString(IDX_COL_LAST_ORDER));
		appSetupBean.setName(cursor.getString(IDX_COL_NAME));
		appSetupBean.setCode(cursor.getString(IDX_COL_CODE));
		return (T) appSetupBean;
	}

	@Override
	public <T extends BaseBean> T cursorInit(Cursor cursor) {
		this.set_id(cursor.getInt(IDX_COL_ID));
		this.setLastOrder(cursor.getString(IDX_COL_LAST_ORDER));
		this.setName(cursor.getString(IDX_COL_NAME));
		this.setCode(cursor.getString(IDX_COL_CODE));
		return (T) this;
	}

	@Override
	public String getCreateTableQuery() {

		return AUTO_GEN_QUERY.getCreateTableQuery();
	}

	@Override
	public String getInsertQuery() {

		return AUTO_GEN_QUERY.getPreparedInsertQuery();
	}

	@Override
	public String getDeleteQuery() {

		return AUTO_GEN_QUERY.getPreparedDeleteQuery();
	}

	@Override
	public String getUpdateQuery() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getTableName() {

		return AUTO_GEN_QUERY.getTableName();
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getLastOrder() {
		return lastOrder;
	}

	public void setLastOrder(String lastOrder) {
		this.lastOrder = lastOrder;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public ContentValues bindContentValues() {

		ContentValues contentValues = new ContentValues();
		contentValues.put(COL_CODE, code);
		contentValues.put(COL_LAST_ORDER, lastOrder);
		contentValues.put(COL_NAME, name);
		return contentValues;
	}

}
